import { fetch } from '@/axios-config/axios'

interface PropsData {
  params?: any
  data?: any
}

export const getListApi = ({ params }: PropsData): any => {
  return fetch({ url: '/edu/teacher/course', method: 'get', params })
}

// 新增或编辑课程信息
export const setApi = ({ data }: PropsData): any => {
  return fetch({ url: '/edu/teacher/course', method: 'post', data })
}

export const getDetApi = ({ params }: PropsData): any => {
  return fetch({ url: `/edu/teacher/course/${params.id}`, method: 'get' })
}

// 获取树形结构的栏目
export const getParentCategoryListApi = (): any => {
  return fetch({ url: `/edu/subject/getParentEduSubjectTreeNode`, method: 'get' })
}

// 保存或更新课程环境
export const setEnvironmenApi = ({ data }: PropsData): any => {
  return fetch({ url: '/edu/teacher/course/saveOrUpdateEnvironmen', method: 'post', data })
}

// 删除环境参数
export const delsApi = ({ data }: PropsData): any => {
  return fetch({ url: `/edu/teacher/course/${data}`, method: 'delete' })
}

// 获取树形课时
export const getChapterTreeListApi = ({ params }: PropsData): any => {
  return fetch({ url: '/edu/teacher/course/chapterTree', method: 'get', params })
}

// 获取视频源
export const getPlayAuthDataApi = ({ params }: PropsData): any => {
  return fetch({ url: `/edu/teacher/course/getPlayAuth/${params.videId}`, method: 'get' })
}

// 获取大章信息
export const getChapterApi = ({ params }: PropsData): any => {
  return fetch({ url: `/edu/teacher/course/chapter/${params.id}`, method: 'get' })
}

// 获取批量上传视频进度
export const getBatchUploadPercentApi = ({ params }: PropsData): any => {
  return fetch({ url: `/edu/teacher/course/getBatchUploadPercent/${params.fileKey}`, method: 'get' })
}

// 保存或更新课程大章
export const setEduChapterApi = ({ params }: PropsData): any => {
  return fetch({ url: '/edu/teacher/course/addEduChapter', method: 'post', params })
}

// 更新课程小节
export const updateVideoApi = ({ data, params }: PropsData): any => {
  return fetch({ url: `/edu/teacher/course/updateVideo/${params.id}`, method: 'put', data })
}

// 删除课程大章数据接口
export const delsEduChapterApi = ({ data }: PropsData): any => {
  return fetch({ url: `/edu/teacher/course/delsEduChapter/${data}`, method: 'delete' })
}

// 删除课程小节数据接口
export const delsEduVideoApi = ({ data }: PropsData): any => {
  return fetch({ url: `/edu/teacher/course/delsEduVideo/${data}`, method: 'delete' })
}

// 获取课程小节信息数据接口
export const getVideoApi = ({ params }: PropsData): any => {
  return fetch({ url: `/edu/teacher/course/video/${params.id}`, method: 'get' })
}

// 获取单个上传视频进度
export const getUploadPercentApi = ({ params }: PropsData): any => {
  return fetch({ url: `/edu/teacher/course/getUploadPercent/${params.id}`, method: 'get' })
}
